package com.wish233.server.impl;

import com.wish233.server.WRpcServer;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.net.NetServer;
import io.vertx.core.parsetools.RecordParser;

/**
 * @author WHH
 * TCP服务器
 */
public class VertxNetServer implements WRpcServer {
    @Override
    public void start(int port) {
        Vertx vertx = Vertx.vertx();
        NetServer netServer = vertx.createNetServer();
        netServer.connectHandler(new NetServerHandler());
        netServer.listen(port, result -> {
            if (result.succeeded()) {
                System.out.println("TCP开始监听端口:" + port);
            } else {
                System.out.println("服务器启动失败" + result.cause());
            }
        });

    }
}
